package ezy.widget.pullrefresh;

import android.view.View;
import android.view.ViewGroup;
import android.widget.ProgressBar;
import android.widget.TextView;

import ezy.widget.R;

public class PullFooter extends PullBase implements IPullIndicator {


    private ProgressBar mProgressBar;
    private TextView mHintView;

    @Override
    public int getPullHeight() {
        return 50;
    }

    @Override
    public View onCreateView(ViewGroup parent) {
        View view = inflate(parent, R.layout.swipe_refresh_footer);

        mProgressBar = findViewById(R.id.swipe_refresh_footer_progressbar);
        mHintView = findViewById(R.id.swipe_refresh_footer_hint);

        return view;
    }

    @Override
    protected void onStateChanged(PullRefreshList.State state, PullRefreshList.State old) {
        mProgressBar.setVisibility(View.GONE);
        mHintView.setVisibility(View.VISIBLE);

        switch (state) {
        case NONE:
            mHintView.setText(R.string.swipe_refresh_footer_none);
            break;
        case NORMAL:
            mHintView.setText(R.string.swipe_refresh_footer_normal);
            break;
        case READY:
            mHintView.setText(R.string.swipe_refresh_footer_ready);
            break;
        case PULLING:
            mHintView.setText(R.string.swipe_refresh_footer_pulling);
            break;
        case LOADING:
            mProgressBar.setVisibility(View.VISIBLE);
            mHintView.setText(R.string.swipe_refresh_footer_loading);
        default:
            break;
        }
    }
}
